<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8 " /> 
<title>回访数据</title> 
<link rel="stylesheet" type="text/css" href="__PUBLIC__/ui/js/themes/default/easyui.css" />
<link rel="stylesheet" type="text/css" href="__PUBLIC__/ui/js/themes/icon.css" />
<style type="text/css">
#fm{margin:0;padding:10px 30px;}
.ftitle{font-size:14px;font-weight:bold;color:#666;padding:5px 0;margin-bottom:10px;border-bottom:1px solid #ccc;}
.fitem{margin-bottom:5px;}
.fitem label{display:inline-block;width:80px;}
.panel{margin:0px auto;}
</style>
<script type="text/javascript" src="__PUBLIC__/ui/js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/ui/js/jquery.easyui.min.js"></script>
<script type="text/javascript">
var url;
//增加节点
function newUser(){
$('#dlg').dialog('open').dialog('setTitle','增加节点');
	$('#fm').form('clear');
	url = '__URL__/node_add';
}
//修改节点
function editUser(){
	var row = $('#dg').datagrid('getSelected');
	if (row){
		$('#dlg').dialog('open').dialog('setTitle','节点修改');
		$('#fm').form('load',row);
		url = '__URL__/node_update/id/'+row.id;
	}
}
//保存节点
function saveUser(){
	$('#fm').form('submit',{
		url: url,
		onSubmit: function(){
			return $(this).form('validate');
		},
		success: function(result){
			var result = eval('('+result+')');
			if (result.success){
				$('#dlg').dialog('close');		// close the dialog
				$('#dg').datagrid('reload');	// reload the user data
				$.messager.show({
					title: '成功',
					msg: '增加数据成功'
				});
			} else {
				$.messager.show({
					title: '错误',
					msg: result.msg
				});
			}
		}
	});
}
//删除节点
function removeUser(){
	var row = $('#dg').datagrid('getSelected');
	if (row){
		$.messager.confirm('删除节点','您确定要删除此节点吗？',function(r){
			if (r){
				$.post('__URL__/node_del',{id:row.id},function(result){
					if (result.success){
						$('#dg').datagrid('reload');	// reload the user data
					} else {
						$.messager.show({	// show error message
							title: '错误',
							msg: result.msg
						});
					}
				},'json');
			}
		});
	}
}
</script>

<body>
	<table align="center" class="easyui-datagrid" id="dg" style="width:1000px;height:450px; text-align:center" title="节点管理"
			url="__GROUP__/User/node_list"
			toolbar="#toolbar" pagination="true"
			rownumbers="true" fitColumns="true" singleSelect="true">
		<thead>
			<tr>
				<th field="id" width="50">节点ID</th>
				<th field="topid" width="50">上级节点</th>
				<th field="name" width="50">节点名称</th>
				<th field="action" width="50">节点路径</th>
			</tr>
		</thead>
	</table>
	<div id="toolbar">
		<a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newUser()">增加</a>
		<a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editUser()">修改</a>
		<a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="removeUser()">删除</a>
	</div>
	
	<div id="dlg" class="easyui-dialog" style="width:400px;height:280px;padding:10px 20px"
			closed="true" buttons="#dlg-buttons">
		<div class="ftitle">节点为允许访问的路径</div>
		<form id="fm" method="post" novalidate>
			<div class="fitem">
				<label>节点名称:</label>
				<input name="name" class="easyui-validatebox" required>
			</div>
			<div class="fitem">
				<label>上级节点:</label>
				<select name="topid">
                	<volist name='topid' id='vo'>
				  		<option value="{$vo.id}">{$vo.name}</option>
                  	</volist>
                    <option value="0" selected="selected">根节点</option>
				</select>
			</div>
			<div class="fitem">
				<label>节点路径:</label>
				<input name="action" class="easyui-validatebox" required>
			</div>
		</form>
	</div>
	<div id="dlg-buttons">
		<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveUser()">保存</a>
		<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">关闭</a>
	</div>
</body>
</html>